<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item>首页</el-breadcrumb-item>
      <el-breadcrumb-item>币种管理</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card class="box-card">
      <!-- 头部搜索 -->
      <!-- <el-row :gutter="10">
        <el-col :span="5">
          <div class="grid-content bg-purple">
            <el-form label-width="80px">
              <el-form-item label="邮箱：">
                <el-input
                  v-model="queryinfo.userEmail"
                  clearable
                  placeholder="请输入邮箱"
                  @clear="getmsgList"
                ></el-input>
              </el-form-item>
            </el-form>
          </div>
        </el-col>
        <el-col :span="5">
          <div class="grid-content bg-purple">
            <el-form label-width="80px">
              <el-form-item label="手机号：">
                <el-input
                  v-model="queryinfo.userTel"
                  clearable
                  placeholder="请输入手机号"
                  @clear="getmsgList"
                ></el-input>
              </el-form-item>
            </el-form>
          </div>
        </el-col>
        <el-button type="primary" icon="el-icon-search" @click="getmsgList"
          >搜索</el-button
        >
      </el-row> -->
      <!-- 数据列表 -->
      <el-table :data="tableData" stripe border style="width: 100%">
        <el-table-column type="index" label="#"> </el-table-column>
        <el-table-column prop="id" label="ID" width="80"> </el-table-column>
        <el-table-column prop="tokenEn" label="币名称"> </el-table-column>
        <el-table-column prop="tokenLogo" label="币logo">
          <template slot-scope="scope">
            <img :src="scope.row.tokenLogo" style="width:45px;height:45px" />
          </template>
        </el-table-column>
        <el-table-column prop="tokenGains" label="币涨幅"> </el-table-column>
        <el-table-column prop="tokenPrice" label="币单价"> </el-table-column>
        <el-table-column prop="tokenPriceUnit" label="单位单价">
        </el-table-column>
        <el-table-column label="修改币信息">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="primary"
              icon="el-icon-edit"
              @click="changeCoin(scope.row)"
              >修改</el-button
            >
          </template>
        </el-table-column>
        <el-table-column  label="查看链类型">
        <template slot-scope="scope">
            <el-button
              size="mini"
              type="danger"
              icon="el-icon-view"
              @click="looKL(scope.row.id)"
              >查看</el-button
            >
          </template>
      </el-table-column>
      </el-table>
      
      <!-- <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :page-sizes="[10, 20, 30]"
        :page-size="queryinfo.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination> -->
    </el-card>
    <!-- 修改币信息-->
    <el-dialog title="修改币信息" :visible.sync="dialogTableVisible">
      <el-row :gutter="20">
        <el-col :span="5">币名称</el-col>
        <el-col :span="18">
          <el-input v-model="formList.tokenEn" placeholder="请输入"></el-input>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="5">币logo</el-col>
        <el-col :span="18">
          <el-input
            v-model="formList.tokenLogo"
            placeholder="请输入"
          ></el-input>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="5"> 币单价</el-col>
        <el-col :span="18">
          <el-input
            v-model="formList.tokenPrice"
            placeholder="请输入"
          ></el-input>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="5">单价单位</el-col>
        <el-col :span="18">
          <el-select v-model="formList.tokenPriceUnit" placeholder="请选择">
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="5">币涨幅 </el-col>
        <el-col :span="18">
          <el-input
            v-model="formList.tokenGains"
            placeholder="请输入"
          ></el-input>
        </el-col>
      </el-row>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submit">提交</el-button>
      </span>
    </el-dialog>
    <!-- 修改链信息-->
    <el-dialog title="修改链信息" :visible.sync="changeLdialog" width="80%" >
      <el-row :gutter="20">
        <el-col :span="5"> 是否在链上</el-col>
        <el-col :span="18">
          <el-switch
            v-model="lInfoQuery.isL"
            active-color="#13ce66"
            inactive-color="#ff4949"
          >
          </el-switch>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="5">外部是否可提</el-col>
        <el-col :span="18">
          <el-switch
            v-model="lInfoQuery.isTb"
            active-color="#13ce66"
            inactive-color="#ff4949"
            @change="isTb"
          >
          </el-switch>
        </el-col>
      </el-row>
      <el-row :gutter="20" v-if="isDisplay">
        <el-col :span="5">提到外部的手续费</el-col>
        <el-col :span="18">
          <el-input v-model="lInfoQuery.tbSxf" placeholder="请输入"></el-input>
        </el-col>
      </el-row>
      <el-alert title="提示：1：%，0：固定值" type="success" v-if="isDisplay"> </el-alert>
      <el-row :gutter="20" v-if="isDisplay">
        <el-col :span="5">外部手续费类型</el-col>
        <el-col :span="18">
          <el-input
            v-model="lInfoQuery.tbSxfType"
            placeholder="请输入"
          ></el-input>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="5">内部是否可提</el-col>
        <el-col :span="18">
          <el-switch
            v-model="lInfoQuery.isNbTb"
            active-color="#13ce66"
            inactive-color="#ff4949"
             @change="isNbTb"
          >
          </el-switch>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="5">是否可充值</el-col>
        <el-col :span="18">
          <el-switch
            v-model="lInfoQuery.isCz"
            active-color="#13ce66"
            inactive-color="#ff4949"
          >
          </el-switch>
        </el-col>
      </el-row>
      <el-row :gutter="20" v-if="isNbTbDisplay">
        <el-col :span="5"> 提到内部的手续费</el-col>
        <el-col :span="18">
          <el-input v-model="lInfoQuery.nbSxf" placeholder="请输入"></el-input>
        </el-col>
      </el-row>
      <el-alert title="提示：1：%，0：固定值" type="success" v-if="isNbTbDisplay"> </el-alert>
      <el-row :gutter="20" v-if="isNbTbDisplay">
        <el-col :span="5">内部手续费类型</el-col>
        <el-col :span="18">
          <el-input
            v-model="lInfoQuery.nbSxfType"
            placeholder="请输入"
          ></el-input>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="5">自动提币审核的额度 </el-col>
        <el-col :span="18">
          <el-input v-model="lInfoQuery.zdShNum" placeholder="请输入"></el-input>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="5"> 提币时间段</el-col>
        <el-col :span="18">
          <el-input v-model="lInfoQuery.tbTime" placeholder="请输入"></el-input>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="5">提币最小最大值 </el-col>
        <el-col :span="18">
          <el-input
            v-model="lInfoQuery.tbInterval"
            placeholder="请输入"
          ></el-input>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="5">汇总阈值 </el-col>
        <el-col :span="18">
          <el-input
            v-model="lInfoQuery.hzNum"
            placeholder="请输入"
          ></el-input>
        </el-col>
      </el-row>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitLInfo">提交</el-button>
      </span>
    </el-dialog>
    <!-- 查看链详情 -->
    <el-dialog
      title="查看链详情"
      :visible.sync="LookLdialogVisible"
      width="50%">
      <el-table :data="LData" stripe border style="width: 100%">
        <el-table-column prop="lType" label="链名称" > </el-table-column>
        <el-table-column prop="tbInterval" label="提币范围" > </el-table-column>
        <el-table-column prop="tbTime" label="提币时间" > </el-table-column>
        <el-table-column prop="id" label="修改" > 
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="danger"
              icon="el-icon-edit"
              @click="changeL(scope.row)"
              >修改</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>
  </div>
</template>
<script>
export default {
  data() {
    return {
      // 修改币信息
      formList: {
        tokenEn: null,
        tokenLogo: null,
        tokenPrice: null,
        tokenPriceUnit: null,
        tokenGains: null,
      },
      // 修改链信息
      lInfoQuery:{
        isL:"",
        isTb:"",
        tbSxf:"",
        tbSxfType:"",
        isNbTb:"",
        nbSxf:"",
        nbSxfType:"",
        zdShNum:"",
        tbTime:"",
        tbInterval:"",
      },
      // queryinfo: {
      //   userTel: "",
      //   userEmail: "",
      //   pageIndex: 1,
      //   pageSize: 10,
      // },
      // total: 0,
      tableData: [],
      dialogTableVisible: false,
      changeLdialog:false,
      gridData: [],
      gridData1: [],
      LData:[],
      options: [
        {
          value: "CNY",
          label: "CNY",
        },
        {
          value: "USDT",
          label: "USDT",
        },
      ],
      isDisplay:true,
      isNbTbDisplay:true,
      LookLdialogVisible:false,
    };
  },
  created() {
    this.getmsgList();
  },
  methods: {
    // 查看链类型
    async looKL(id) {
      const Ltype ={id}
      this.LookLdialogVisible = true
       const { data: res } = await this.$http.post(
        "currencyAudit/getCoinTypeList",
        this.httputil(Ltype)
      );
      if (res.code !== 200) return this.$message.error(res.msg);
      this.LData = res.data;
    },
    // 修改链信息
    async changeL(row) {
      this.changeLdialog = true;
      this.lInfoQuery = row;
      this.isTb()
      this.isNbTb()
    },
    // 修改币信息
    async changeCoin(row) {
      this.dialogTableVisible = true;
      this.formList = row;
    },
    // 确认提交修改链信息
    async submitLInfo() {
      const { data: res } = await this.$http.post(
        "currencyAudit/updateCoinType",
        this.httputil(this.lInfoQuery)
      );
      if (res.code !== 200) return this.$message.error(res.msg);
      this.$message.success(res.msg);
      this.getmsgList();
      this.changeLdialog = false;
    },
    // 确认提交修改币信息
    async submit() {
      const { data: res } = await this.$http.post(
        "currencyAudit/updateCoin",
        this.httputil(this.formList)
      );
      if (res.code !== 200) return this.$message.error(res.msg);
      this.$message.success(res.msg);
      this.getmsgList();
      this.dialogTableVisible = false;
    },
    // 获取币种记录列表
    async getmsgList() {
      const { data: res } = await this.$http.post(
        "currencyAudit/getCoinListm",
        this.httputil(this.queryinfo)
      );
      if (res.code !== 200) return this.$message.error(res.msg);
      this.tableData = res.data;
      // this.total = res.data.count;
    },
    // 页面数量发生改变
    handleSizeChange(newSize) {
      this.queryinfo.pageSize = newSize;
      this.getmsgList();
    },
    // 页数发生改变
    handleCurrentChange(newCurrent) {
      this.queryinfo.pageIndex = newCurrent;
      this.getmsgList();
    },
    isTb(){
      if(this.lInfoQuery.isTb){
        this.isDisplay = true
      }else{
        this.isDisplay = false
      }
    },
    isNbTb(){
      if(this.lInfoQuery.isNbTb){
        this.isNbTbDisplay = true
      }else{
        this.isNbTbDisplay = false
      }
    }
  },
  watch: {
    
  },
};
</script>
<style lang="less" scope>
.el-row {
  margin: 15px 0;
}
</style>
